import http from '..';
import { Sample } from '../model/sample';
import { formatQuery } from '/@/libs/utils/format';

// 获取样本列表
export const getSamples = (page?: number, pageSize?: number) =>
  http.get(`/samples?${page || pageSize ? formatQuery({ page, pageSize }) : ''}`);

// 获取样本详情
export const getSampleDetail = (sampleId: string) => http.get(`/samples/${sampleId}`);

// 新建样本
export const setSample = (data: Sample) => http.post('/samples', data);

// 上传excel导入样本信息
export const setSamples = (file: FormData) => http.post('/samples/import', file);

// 更新样本
export const updateSample = (sampleId: string, data: Sample) =>
  http.put(`/samples/${sampleId}`, data);

// 关联样本和task
export const updateSampleAssociate = (taskId: string, sampleId: string) =>
  http.put(`/samples/${sampleId}/associate/${taskId}`);

// 删除样本
export const deleteSample = (sampleId: string) => http.delete(`/samples/${sampleId}`);
